<template>
  <div>
    <!-- 标题区域 -->
    <van-nav-bar title="房屋管理" left-arrow @click-left="onClickLeft" />
    <!-- 列表 -->
    <div class="list" v-for="(item) in list" :key="item.houseCode">
      <div class="left">
        <img
          :src="`http://liufusong.top:8080${item.houseImg}`"
          alt=""
        />
      </div>
      <div class="right">
        <div class="title">
          <h3>{{item.title}}</h3>
        </div>
        <div class="desc"><p>{{item.desc}}</p></div>
        <div class="tag"><span>{{item.tags[0]}}</span></div>
        <div class="price"><strong>{{item.price}}</strong>元/月</div>
      </div>
    </div>
  </div>
</template>

<script>
import { hire } from '@/api/home.js'
export default {
  data () {
    return {
      list: []
    }
  },
  methods: {
    onClickLeft () {
      this.$router.back()
    }
  },
  async created () {
    const res = await hire()
    if (!res.body) {
      this.$toast('请先登录哦~')
      this.$router.push('/login')
    }
    this.list = res.body
  }
}
</script>

<style lang="less" scoped>
.list {
  display: flex;
  height: 120px;
  padding-top: 18px;
  box-sizing: border-box;
  .left {
    img {
      width: 106px;
      height: 80px;
    }
  }
  .right {
    margin-left: 15px;
    .title {
      transform: translateY(-15px);
      font-size: 13px;
    }
    .desc {
      font-size: 12px;
      color: #9999;
      transform: translateY(-27px);
    }
    .tag {
      display: inline-block;
      font-size: 12px;
      border-radius: 3px;
      padding: 4px 5px;
      margin-right: 5px;
      line-height: 12px;
      color: #39becd;
      background: #e1f5f8;
      transform: translateY(-35px);
    }
    .price{
      color: red;
      transform: translateY(-35px);
    }
  }
}
</style>
